# encoding=utf8
import sys
reload(sys)
sys.setdefaultencoding('utf8')

class FT_8789:
    result=[]
    analysisDecription = ['自定义消息体长度：','数据上报许可项总数：','数据上报许可项列表：']
    # 2，1，3*n
    analysis8789Length=[2,1,0]
    #2，1
    data=["数据ID：","上报许可："]
    data_list=[
        "普通超速", "严重超速", "过长怠速", "急转弯", "急刹车", "急加速", "超转行驶", "空挡滑行", "停车立即熄火", "冷车行驶",
        "低油量行驶", "冷却系统异常", "长时间刹车","长时间离合", "粘离合", "发动机异常熄火", "停车状态踩踏油门", "机油油温异常",
        "机油压力低", "运行中机油压力低", "机油油压过高", "电瓶电压高", "电瓶电压低", "蓄电瓶低压异常","蓄电瓶高压异常",
        "猛踩油门", "燃油温度过高", "下坡空档滑行", "高档低速", "停车长时间开空调", "预留", "安全带未系", "转弯未打转向灯",
        "远灯使用不当", "低档高速", "疲劳驾驶","带手刹行驶", "带故障行驶"
        ]

    def LogicAisle(self, protocolStr, header):
        s = protocolStr[0:4]
        header.append(self.analysisDecription[0] + s + '\n')
        data_total=int(protocolStr[4:6],16)
        header.append(self.analysisDecription[0] + str(data_total) + '\n')
        s=protocolStr[6:]
        for i in range(data_total):
            dataid=s[0:4]
            num=int(dataid,16)
            header.append(self.data[0]+dataid+self.data_list[num-1]+'\n')
            xuke=s[4:6]
            msg=''
            if xuke=="00":
                msg='不允许'
            elif xuke=="01":
                msg='允许'
            header.append(self.data[1]+xuke+msg+'\n')
            s=s[6:]
        self.result=header
